<?php
//include ('ind/config.php');
?><table   border=0>
<tr style="background-color:#F79307">
<td>Kd barang</td><td>Nama barang</td><td>Stok</td><td>Harga</td><td>Operasi</td></tr>

<?php
/*
* kode untuk menghapus data
*/
if(isset($_GET['del'])){
$kd_barang=$_GET['id'];
$hapus ="delete from barang where kd_barang='$kd_barang'";
mysql_query($hapus) or die(mysql_error());

}
$sql="";
if(isset($_POST['btnCari'])){
$cari=$_POST['cari'];
//ambil data dari table admin
$sql="SELECT * FROM  barang where kd_barang like '%$cari%'";
}else{
$sql="SELECT * FROM  barang";
}

$result=mysql_query($sql) or die(mysql_error());

//proses menampilkan data
while($rows=mysql_fetch_array($result)){
?>
<tr>

<td><?php  echo $rows['kd_barang'];?></td>

<td><?php  echo $rows['nama_barang'];?></td>

<td><?php  echo $rows['stok'];?></td>
<td><?php  echo $rows['harga'];?></td>
<td>
<!--<a href="index.php?page=barang_form_edit&id=<?php echo $rows['kd_barang']?>">
<img src="image/b_edit.png"></a>-->
<a href="index.php?page=barang_view&del=true&id=<?php echo $rows['kd_barang']?>"  onclick="return askUser()";>
<img src="image/b_drop.png"></a>|
detail
</td>
</tr>

<?php
}

//tutup koneksi
?>
<tr><td align=right colspan='4'>
<?php
if (isset($_GET['status'])) {
	if ($_GET['status'] == 0) {
		echo " Operasi data berhasil";
	} else {
		echo "operasi gagal";
	}
}
?>
</td>
<td align=right><a href="index.php?page=barang_form_add">
<img src="image/add.jpg"> Tambah</a></td></tr>
<td align=right><a href="barang_cetak.php" target='_blank'>
cetak</a></td></tr>
<tr></tr>
</table>
<?php

mysql_close();
//close database

//tampilan siapa yang login
?>

